home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / getkey11.zip / GETKEY.DOC < prev    next >
Text File  |  1993-12-06  |  5KB  |  140 lines

  1.  
  2.  
  3.                               GetKey 1.11
  4.                             December 6, 1993
  5.  
  6.  
  7.  
  8.                      A Batch File enhancing command
  9.                   to allow full usage of the keyboard
  10.  
  11.  
  12.  
  13.           Copyright (c) 1992-1993 Chad Knudson, All Rights Reserved
  14.  
  15.  
  16.     GetKey is a command to use in Batch files to allow polling for any
  17.     keypress of the keyboard.  It was written for developing a menu 
  18.     system in DOS Batch (.BAT) files.
  19.  
  20.     Setup
  21.     -----
  22.     Operation of GetKey is quite simple. You will want to place the 
  23.     GETKEY.EXE file either in the directory that your .BAT file resides 
  24.     or in a directory in your DOS PATH statement. That's all that you 
  25.     need to do for setting up GetKey.
  26.  
  27.     Operation
  28.     ---------
  29.     GetKey is designed for use in .BAT files.  When you call GetKey in a 
  30.     .BAT file, it will wait until the next keypress occurs and then will 
  31.     store a textual representation of that key in the DOS environment 
  32.     variable KEY.  Here are some samples of what GetKey places in KEY:
  33.  
  34.     ────────────┬───────────────────────────────────────────────────────
  35.     KEY=        │ Keystroke
  36.     ────────────┼───────────────────────────────────────────────────────
  37.     F10         │ Function key F10 pressed
  38.     A           │ Capital A pressed
  39.     CTRL-HOME   │ CTRL and HOME keys pressed simultaneously
  40.     ALT-X       │ ALT and X keys pressed simultaneously
  41.     ESC         │ Escape key pressed
  42.     ALT-F12     │ ALT and Function Key F12 pressed simultaneously
  43.     ???         │ 5 pressed on numeric keypad when NumLock off
  44.  
  45.     As you can see, it allows for nearly any keystroke combination to be 
  46.     polled.  If GetKey doesn't recognize the keypress, it places three 
  47.     question marks in KEY.  The majority of keypresses are available to 
  48.     you to use, but there are a few that I excluded.  To make sure that 
  49.     the keypress you wish to use is valid, try it manually.  Type 
  50.     GETKEY, press the keypress in question, and type SET at the DOS 
  51.     prompt to see your current environment setting.  (A sample of how to 
  52.     do this is included in the file TESTKEY.BAT which will probably 
  53.     suffice for any testing you need to do.)
  54.     
  55.     Using GetKey in a .BAT file
  56.     ---------------------------
  57.     Below is a sample batch file (also included in this .ZIP is a file
  58.     RUNME.BAT, which is a more in-depth demonstration) which 
  59.     demonstrates how you can utilize GetKey in your own batch file.
  60.  
  61.     TESTME.BAT
  62.     ───┬────────
  63.      1 │ @Echo off
  64.      2 │ Cls
  65.      3 │ Echo This is a simple demonstration of how to use GETKEY in your own
  66.      4 │ Echo .BAT files.  It is not intended to be an exhaustive demonstration,
  67.      5 │ Echo but rather
  68.      6 │ Echo to get you going in the right direction.
  69.      7 │ Echo.
  70.      8 │ Echo.
  71.      9 │ Echo On
  72.     10 │ :start
  73.     11 │ Echo -={ Press <F1> to continue }=-
  74.     12 │ GETKEY
  75.     13 │ IF %KEY%==F1 goto item1
  76.     14 │ goto start
  77.     15 │ :item1
  78.     16 │ Echo.
  79.     17 │ Echo Good!  You're getting the hang of it.
  80.     ───┴───────
  81.  
  82.     Notes About Specific Lines:
  83.  
  84.     Line 10 This is a label in a batch file, it enables us to use the
  85.             goto command to transfer control within the batch file.  
  86.             This particular label will set up the starting point of our 
  87.             menu, and we'll always return to this when we've completed 
  88.             another task.  See the included RUNME.BAT file for a better 
  89.             example of how this works.
  90.     Line 12 Call GETKEY
  91.     Line 13 Test the environment variable KEY to see if it equals one of
  92.             our menu choices.
  93.     Line 14 If it made it this far, no menu choice was selected so we
  94.             should go back and get a valid menu selection.
  95.  
  96.     
  97.     About GetKey and CKWare
  98.     -----------------------
  99.     GetKey was written by Chad Knudson while attending the University of 
  100.     North Dakota majoring in Computer Science and Mathematics.  It was 
  101.     written in 'C' and compiled with Microsoft C 7.0.
  102.  
  103.     Chad has developed a number of utilities for Bulletin Board Systems 
  104.     as well as DOS utilities.  To see the latest collection of CKWare 
  105.     products, call City Lites BBS (701) 772-5399.
  106.  
  107.     If you feel that GETKEY is useful to you, feel free to use it.  If 
  108.     you'd like to make a donation to the author, you're certainly 
  109.     encouraged to but not obligated.  Send donations to:
  110.  
  111.     CKWare (GetKey)
  112.     Chad Knudson
  113.     P.O. Box 112
  114.     Towner, ND  58788
  115.  
  116.     I can also take your questions, comments, and bug reports via 
  117.     e-mail at:
  118.  
  119.     Internet
  120.     ──────────
  121.     knudson@cs.und.nodak.edu
  122.  
  123.     RIME
  124.     ──────────
  125.     ->CITYLITE
  126.  
  127.     FIDO
  128.     ──────────
  129.     1:14/644
  130.  
  131.  
  132.     Credits
  133.     -------
  134.     A special thanks goes out to H. D. Todd, Wesleyan University, for
  135.     steering me in the right direction as to how one could manipulate 
  136.     variables in the parent process' environment (the documentation in 
  137.     the C Compilers said that this could not be done, at least not using 
  138.     the putenv() function that the compiler provides.)  Without his help 
  139.     this program wouldn't have been possible.
  140.